/**
 * 消息通知
 * @author luguoxiang
 * @date 2023-03-29
 * 开源项目：https://gitee.com/lgx1992/lg-soar 求star！请给我star！请帮我点个star！
 */
import { IConfigSchema, LgBizSelect, LgBizSelectProps, LgDictProps } from '@/soar';
import userApi from '../../auth/user/api';
import MultiplePicker from '@/pages/auth/user/Picker/MultiplePicker.vue';

const fieldList: IConfigSchema<any>[] = [
  {
    field: 'content',
    label: '通知内容',
    dataType: 'string',
    table: {
      ellipsis: true,
    },
    form: {
      rules: true,
      component: 't-textarea',
    },
  },
  {
    field: 'datetime',
    label: '通知时间',
    dataType: 'datetime',
    table: {
      width: 160,
    },
    form: {
      rules: true,
    },
  },
  {
    field: 'type',
    label: '通知类型',
    dataType: 'dict',
    params: 'NoticeTypeEnum',
    table: {
      width: 120,
    },
    form: {
      rules: true,
      componentProps: {
        component: 't-radio-group',
      } as LgDictProps,
    },
  },
  {
    field: 'recipientType',
    label: '接收人类型',
    dataType: 'dict',
    params: 'NoticeRecipientTypeEnum',
    table: {
      width: 120,
    },
    form: {
      rules: true,
      componentProps: {
        component: 't-radio-group',
      } as LgDictProps,
    },
  },
  {
    field: 'userIds',
    label: '接收人',
    dataType: 'string',
    table: false,
    form: {
      vif({ data }) {
        return data.recipientType === 1;
      },
      rules({ data }) {
        return data.recipientType === 1 ? [{ required: true, message: '请选择接收人' }] : [];
      },
      component: MultiplePicker,
      componentProps: {
        input: true,
      },
    },
  },
  {
    field: 'bizType',
    label: '业务类型',
    dataType: 'string',
    form: {
      rules: true,
    },
  },
  {
    field: 'bizParams',
    label: '业务参数',
    dataType: 'string',
    form: {
      component: 't-textarea',
    },
  },
];

export default fieldList;
